const express = require("express");
const app = express();
app.use(express.json());// 1- 将请求体的数据-json放置到req.body中 2- 执行next
app.use(express.urlencoded());// / 1- 将请求体的数据-urlencoded放置到req.body中 2- 执行next
// get http://zhangpeiyue.com:8091/info/100/200?a=1&b=2
app.get("/info/:id/:type",(req,res)=>{
	console.log(req.url);// /info?a=1&b=2
	console.log(req.query);// {a:'1',b:'2'}
	console.log(req.params);// {id:'100',type:'200'}
	console.log(req.headers);// 获取请求头信息
	console.log(req.headers.host);// 'zhangpeiyue.com:8091
	console.log(req.get("host"));// 'zhangpeiyue.com:8091
	res.send("ok1");
});
app.post("/info",(req,res)=>{
	console.log(req.method);// 获取请求方式
	console.log(req.body);// 请求体
	res.send("ok2");
})
app.listen(8091,()=>{
	console.log("success");
})